# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit eutils qt4 toolchain-funcs

DESCRIPTION="Winamp-like audio player written with Qt4"
HOMEPAGE="http://qmmp.ylsoftware.com/"
SRC_URI="http://qmmp.ylsoftware.com/files/${P}.tar.bz2"

LICENSE="GPLv2"
SLOT="0"
KEYWORDS="~x86"
IUSE="alsa jack flac musepack ffmpeg mad vorbis"

RDEPEND=">=x11-libs/qt-4.3:4
               >=media-libs/libmad-0.15.1b
               >=media-libs/libvorbis-1.1.2
               flac? ( >=media-libs/flac-1.1.3 )
               >=media-libs/taglib-1.4
               alsa? ( >=media-libs/alsa-lib-1.0.1 )
               mad? ( >=media-libs/libmad-0.15.1b )
               musepack? ( >=media-libs/libmpcdec-1.2.5 )
               vorbis? ( >=media-libs/libvorbis-1.1.2 )
               jack? ( >=media-sound/jack-audio-connection-kit-0.102.5 )
               ffmpeg? ( >=media-video/ffmpeg-0.4.9_p20070330 )
               >=dev-util/cmake-2.4"

DEPEND="${RDEPEND}"

src_unpack() {
       unpack ${A}
       cd ${S}
}

src_compile() {
       CMAKEOPTS="-DCMAKE_INSTALL_PREFIX=/usr"
       einfo "Enabled plugins:"
       if use jack; then
               einfo "  JACK"
       else
               CMAKEOPTS="${CMAKEOPTS} -DUSE_JACK:BOOL=FALSE"
       fi
       if use alsa; then
               einfo "  ALSA"
       else
               CMAKEOPTS="${CMAKEOPTS} -DUSE_ALSA:BOOL=FALSE"
       fi
       if use flac; then
               einfo "  FLAC"
       else
               CMAKEOPTS="${CMAKEOPTS} -DUSE_FLAC:BOOL=FALSE"
       fi
       if use vorbis; then
               einfo "  Ogg Vorbis"
       else
               CMAKEOPTS="${CMAKEOPTS} -DUSE_VORBIS:BOOL=FALSE"
       fi
       if use musepack; then
               einfo "  Musepack"
       else
               CMAKEOPTS="${CMAKEOPTS} -DUSE_MPC:BOOL=FALSE"
       fi
       if use mad; then
               einfo "  MAD"
       else
               CMAKEOPTS="${CMAKEOPTS} -DUSE_MAD:BOOL=FALSE"
       fi
       if use ffmpeg; then
               einfo "  FFmpeg"
       else
               CMAKEOPTS="${CMAKEOPTS} -DUSE_FFMPEG:BOOL=FALSE"
       fi
       cmake ${CMAKEOPTS} || die "cmake failed"
       emake || die "emake failed"
}

src_install() {
       emake DESTDIR=${D} install || die "emake install failed"

       dodoc COPYING README README.RUS AUTHORS ChangeLog ChangeLog.rus
}

